package com.study.sbsummary.service;

import com.study.sbsummary.dao.OrderDao;
import com.study.sbsummary.model.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDao mapper;

    @Override
    public List<Order> listOrder() {
        return mapper.selectAll();
    }

    @Override
    @Transactional
    public int addOrder(Order order) {
        int insert = mapper.insert(order);
        return insert;
    }

    @Override
    public int updateOrder(Order order) {
        int update = mapper.update(order);
        return update;
    }

    @Override
    public Order selectOrderById(Long id) {
        Order order = mapper.selectById(id);
        return order;
    }
}
